#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>

int un_g_val;
int g_val = 100;

int main(int argc, char* argv[], char* env[]) 
{
    printf("text: %p\n",main);//代码区
    printf("init: %p\n",&g_val);//全局初始化区
    printf("uninit: %p\n",&un_g_val);//全局未初始化区
    
    char *p = (char*)malloc(16);
    char *p2 = (char*)malloc(16);
    char *p3 = (char*)malloc(16);
    char *p4 = (char*)malloc(16);
    printf("heaap: %p\n",p); //堆地址
    printf("heaap2: %p\n",p2); //堆地址
    printf("heaap3: %p\n",p3); //堆地址
    printf("heaap4: %p\n",p4); //堆地址

    printf("stack: %p\n",&p);//栈地址
    printf("stack2: %p\n",&p2);//栈地址
    printf("stack3: %p\n",&p3);//栈地址
    printf("stack4: %p\n",&p4);//栈地址
    return 0;

    //int a = 1;
    //int b = 2;
    //int c = 3;
    //printf("a: %p\n",&a);
    //printf("b: %p\n",&b);
    //printf("c: %p\n",&c);

    //if(argc != 2)
    //{
    //    printf("Usage: %s至少有一个选项\n",argv[0]);
    //    return 1;
    //}
    //if(strcmp("-a",argv[1]) == 0)
    //{
    //    printf("这个是功能一\n");
    //}
    //else if(strcmp("-b",argv[1]) == 0)
    //{
    //    printf("这个是功能二\n");
    //}
    //return 0;

    //int i = 0;
    //for(i = 0; i < argc; ++i )
    //{
    //    printf("argv[%d]: %s\n",i,argv[i]);
    //}
    //printf("begin..............................................\n");
    //printf("%s\n",getenv("test"));
    
    //查看系统环境变量的方法1
    //int i = 0;
    //for(i = 0; env[i]; i++)
    //{
    //    printf("env[%d]:%s\n",i,env[i]);
    //}
    //查看系统环境变量的方法2
    //extern char** environ;
    //int i = 0;
    //for(i = 0; environ[i]; i++)
    //{
    //     printf("env[%d]:%s\n",i,environ[i]);
    //}
    //printf("end................................................\n");
   // pid_t id = fork();
   // if(id == 0)
   // {
   //     //child
   //     while(1)
   //     {
   //         printf("hello world\n");
   //         sleep(1);
   //     }

   // }
   // else
   // {
   //     //father
   //     int cnt = 5;
   //     while(cnt)
   //     {
   //         printf("I am father: %d\n",cnt--);
   //         sleep(1);
   //     }
   // }
   // return 0;
   
 //   while(1)
 //   {
 //       printf("hello world,pid: %d\n",getpid());
 //       sleep(1);
 //   }
 //   return 0;

    

}

